package com.jiang.dto.request;

import com.jiang.utils.ValidateData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

/**
 * @author Jiang Junsheng
 * @create 2019/3/19
 * @since 1.0.0
 */
@Data
@Api(hidden = true)
@ApiModel("更新和添加参数")
public class DeptForm {
	@ApiModelProperty(value = "部门：更新必传",example = "123")
	private Long deptId;

	@ApiModelProperty(value = "父部门ID",example = "123")
	private Long pid;

	@ApiModelProperty(value = "父部门ID集合",example = "12,123,")
	private String pids;

	@ApiModelProperty(value = "简称",example = "开发部")
	private String simpleName;

	@ApiModelProperty(value = "全称",example = "研发开发部")
	private String fullName;

	@ApiModelProperty(value = "描述",example = "这是研发部门")
	private String description;

	@ApiModelProperty(value = "排序:越小越靠前",example = "0")
	private Integer sort;

	public ValidateData validate(boolean isUpdate) {
		ValidateData valid = new ValidateData();
		StringBuffer msg = new StringBuffer();
		boolean status = true;
		if(isUpdate&&deptId==null){
			status = false;
			msg.append("部门ID不能为空!\n");
		}
		if (StringUtils.isEmpty(simpleName)) {
			status = false;
			msg.append("简称不能为空!\n");
		}
		if (StringUtils.isEmpty(fullName)) {
			status = false;
			msg.append("全称不能为空!\n");
		}
		valid.setStatus(status);
		valid.setMessage(msg.toString());
		return valid;
	}
}
